<template>
  <div>
    <el-table size="large" v-loading="pager.loading" :data="pager.lists">
      <el-table-column label="反馈ID" prop="proposalId" min-width="120" />
      <el-table-column label="用户名称" prop="userName" min-width="120" />
      <el-table-column label="用户ID" prop="userId" min-width="120" />
      <el-table-column label="手机号" prop="phone" min-width="120" />
      <el-table-column label="内容" prop="content" min-width="120" />
      <el-table-column label="状态" min-width="120">
        <template #default="{ row }">
          <el-tag v-if="row.status === 1">已采纳</el-tag>
          <el-tag type="danger" v-else>未采纳</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="操作" min-width="120" fixed="right">
        <template #default="{ row }">
          <el-button
            v-show="row.status !== 1"
            type="primary"
            link
            @click="adoptProposalFun(row.proposalId)"
          >
            采纳
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <div class="flex justify-end mt-4">
      <pagination v-model="pager" @change="getLists" />
    </div>
  </div>
</template>
<script lang="ts" setup name="shortLetter">
import { getProposalList, adoptProposal } from "@/api/admin/index";
import { usePaging } from "@/hooks/usePaging";
import feedback from "@/utils/feedback";

// 列表数据
const state = reactive({
  loading: false,
  lists: [],
});

const { pager, getLists, resetPage, resetParams } = usePaging({
  fetchFun: getProposalList,
});

const adoptProposalFun = (id: any) => {
  adoptProposal({ id, reply: 1 }).then((res) => {
    feedback.msgSuccess("操作成功");
    getLists();
  });
};
// 获取存储引擎列表数据
/* const getLists = async () => {
  try {
    state.loading = true;
    state.lists = await getProposalList();
    state.loading = false;
  } catch (error) {
    state.loading = false;
  }
}; */

getLists();
</script>
